#ifndef	__ZEALINK_WRITE_CACHE__
#define	__ZEALINK_WRITE_CACHE__
/////////////////////////////////////////////////////////////////////////////
class write_cache:public zwl_thread
{
	typedef struct tagItem
	{
		safe_file*pfile;
		tagItem*pnext;
		DWORD	offset;
		DWORD	size;
		char	buffer[1];
	}ITEM,*PITEM;
public:
	virtual void timeslice(void);

	void register_file(safe_file*pfile);
	void unregister_file(safe_file*pfile);
	
	long write_direct(long num);
	BOOL register_cache(safe_file*pfile,DWORD offset,DWORD size,LPCVOID buffer);

	write_cache(void);
	~write_cache(void);
private:
	PITEM	__items__,__end__;
	safe_file*__files__;
	CRITICAL_SECTION __cs_cache__,__cs_file__;
	long	last_minute;
};
/////////////////////////////////////////////////////////////////////////////
extern class write_cache wtcache;
/////////////////////////////////////////////////////////////////////////////
#endif
